package com.qp.basics.estivate.transaction.support;

import com.qp.basics.estivate.transaction.TransactionStatus;

public class DefaultTransactionStatus implements TransactionStatus {

	private final Object transactionObject;

	private boolean completed = false;
	private boolean newTransaction;
	private final boolean readOnly;

	public DefaultTransactionStatus(Object transactionObject,
			boolean newTransaction, boolean readOnly) {
		this.transactionObject = transactionObject;
		this.newTransaction = newTransaction;
		this.readOnly = readOnly;
	}

	public void setCompleted() {
		this.completed = true;
	}

	public boolean isCompleted() {
		return this.completed;
	}

	public boolean isReadOnly() {
		return this.readOnly;
	}

	public boolean isNewTransaction() {
		return (hasTransaction() && this.newTransaction);
	}

	public boolean hasTransaction() {
		return (this.transactionObject != null);
	}

	public Object getTransactionObject() {
		return this.transactionObject;
	}

}
